﻿#include "GateWayManageWidget.h"
#include "ui_GateWayManageWidget.h"
#include "CommonFunc.h"
#include <QStackedWidget>
#include "DataInfo.h"

#include <QDebug>

GateWayManageWidget::GateWayManageWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GateWayManageWidget)
{
    ui->setupUi(this);

    appendTypeToFunc(XShowGateWay, std::bind(&GateWayManageWidget::showGateWayAllInfo, this));

}

GateWayManageWidget::~GateWayManageWidget()
{
    delete ui;
}

void GateWayManageWidget::showGateWayAllInfo()
{
    if (g_iProductLineID == -1)
    {
        g_vecGateWay.clear();
        ui->gateWayWidget->showGateWayInfo();
        return;
    }

    for (int i = 0; i < g_vecProductInfo.size(); ++i)
    {
        const ProductInfo& pi = g_vecProductInfo[i];
        if (pi.id == g_iProductLineID)
        {
            QString title = QString("%1-%2").arg(pi.strName).arg(QStringLiteral("网关列表"));
            ui->pushButton_title->setText(title);
            ui->gateWayWidget->showGateWayInfo();
            break;
        }
    }

}

void GateWayManageWidget::clearGateWayInfo()
{
    g_vecGateWay.clear();
    ui->gateWayWidget->showGateWayInfo();
}

void GateWayManageWidget::on_toolButton_return_clicked()
{
    executeFuncFromID(XUI_Login);
}

void GateWayManageWidget::on_toolButton_returnPre_clicked()
{
    executeFuncFromID(XUI_AreaManage);
}
